<template>
  <div v-if="isShow" class="mask" @click="hideControl">
    <section class="section">
      <input
        :class="[
          'border-input',
          results.length ? 'border-input-focus' : 'border-input',
        ]"
        @click.stop="inputFocus"
        placeholder="hi rinvay"
        type="text"
      />
      <section
        :class="results.length ? 'border-results' : 'border-results-focus'"
      >
        <div class="results" v-for="(item, index) in results" :key="index">
          <span>{{ item.name }}</span
          ><span :class="cateNumColor[item.cateNum]">{{ item.cate }}</span>
        </div>
      </section>
    </section>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isShow: false,
      cateNumColor: ["bg-green", "bg-orange", "bg-yellow"],
      results: [],
      results1: [
        {
          name:
            "所有评优材料一定要看格式符不符合要求，如果交上来的不符合字体格式要求，直接不考虑上报@全体成员",
          cate: "🔖标签",
          cateNum: 2,
        },
        { name: "Vue", cate: "⚽分类", cateNum: 1 }
      ],
    };
  },
  methods: {
    hideControl() {
      this.isShow = !this.isShow;
    },
    inputFocus() {
      // console.log(1);
      // this.results = this.results1;
      // console.log(this.results);
    },
  },
};
</script>
<style lang='scss' scoped>
.mask {
  position: fixed;
  z-index: 66;
  background: rgba(0, 0, 0, 0.5);
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  backdrop-filter: blur(4px);
}
.section {
  position: fixed;
  z-index: 99;
  width: 800px;
  top: 180px;
  left: 50%;
  transform: translateX(-50%);
  .border-input {
    border: none;
    border-bottom: 2px solid #46c47c;
    background-color: rgba(0, 0, 0, 0);
    color: #fff;
  }
  input {
    box-sizing: border-box;
    width: 100%;
    height: 58px;
    padding: 5px 15px;
    font-size: 20px;
    outline: none;
    &::placeholder {
      color: rgba(255, 255, 255, 0.5);
    }
  }
  section {
    max-height: 550px;
    overflow: auto;
  }
  .results {
    cursor: pointer;
    width: 100%;
    height: 55px;
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0);
    color: #fff;
    box-sizing: border-box;
    padding: 0 10px;
    &:hover {
      background-color: rgba(0, 0, 0, 0.1);
    }
  }
  .results span:first-child {
    font-size: 18px;
    padding: 0 10px 0 0;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 10;
  }
  .results span:last-child {
    display: block;
    flex: 1;
    text-align: center;
    padding: 2px 4px;
    border-radius: 20px;
    color: #fff;
  }
}
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
  border-radius: 5px;
  background-color: rgba(0, 0, 0, 0.2);
}
</style>